package io.renren.modules.workerplan.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.workerplan.entity.WorkerplanEntity;
import io.renren.modules.workerplan.service.WorkerplanService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-08-04 19:18:51
 */
@RestController
@RequestMapping("workerplan/workerplan")
public class WorkerplanController {
    @Autowired
    private WorkerplanService workerplanService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("workerplan:workerplan:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = workerplanService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{workerNo}")
    @RequiresPermissions("workerplan:workerplan:info")
    public R info(@PathVariable("workerNo") Integer workerNo){
		WorkerplanEntity workerplan = workerplanService.getById(workerNo);

        return R.ok().put("workerplan", workerplan);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("workerplan:workerplan:save")
    public R save(@RequestBody WorkerplanEntity workerplan){
		workerplanService.save(workerplan);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("workerplan:workerplan:update")
    public R update(@RequestBody WorkerplanEntity workerplan){
		workerplanService.updateById(workerplan);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("workerplan:workerplan:delete")
    public R delete(@RequestBody Integer[] workerNos){
		workerplanService.removeByIds(Arrays.asList(workerNos));

        return R.ok();
    }

}
